package 笔试.携程;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/5/27-19:56
 * @version:1.0
 * @function:
 */
public class xc02 {
    public static List<List<Integer>> res = null;
    public static void main(String[] args) {
        res = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int[][]r =new int[n+1][n+1];
        String[] line = scanner.nextLine().split(" ");
        for (String s1 : line) {
            String[] split = s1.split(",");
            int i = Integer.parseInt(split[0]);
            int j = Integer.parseInt(split[1]);
            r[i][j] = 1;
        }
        int s = scanner.nextInt();
        int t = scanner.nextInt();
        int k = scanner.nextInt();
        findPath(r,s,t,k);
        System.out.println(res.toString());
    }
    static void   findPath(int[][] r, int s, int t, int k){
        List<List<Integer>> res = new ArrayList<>();
//        for (int i = 0; i <= k; i++) {
            check(r,s,t,k,null);
//        }
    }

    static void check(int[][] r, int s, int t, int k,List<Integer> path ) {
        if (path==null){
            path = new ArrayList<>();
            path.add(s); // 添加起始站点
        }
        if (s==t){
            res.add(new ArrayList<>(path)) ;
        }
        else if (k > 0) {
            for (int i = 0; i < r.length; i++) {
                if (r[s][i]==1){
                    List<Integer> p = new ArrayList<>(path);
                    p.add(i);
                    check(r,i,t,k-1,p);
                }
            }
        }
    }
}
